#
#  Makefile for Horizon - user applications
#
#  Francesco Frigo
#  Tuesday 20th February, 2007
#
#  Updated on: Tuesday 20th February, 2007
#

INCLUDEDIR = -I../lib/include
CFLAGS = -nostdinc -nostdlib -nostartfiles -fno-builtin -fwritable-strings -Wall -W -g
LIBDIR = ../lib

CC=gcc-3.3

ENTRY = _crt0
RELOC = 0x00000000
OUTF = a.out
#DBG_OUTF = system-dbg.o

OBJS = $(LIBDIR)/crt0.o *.o $(LIBDIR)/libc.a 

all: $(OUTF)

#debug: $(OUTF)
#	ld -T linker-dbg.ld -Ttext $(RELOC) --entry $(ENTRY) -L$(LIBDIR) -o $(DBG_OUTF) $(OBJS) --warn-common


$(OUTF):
	$(CC) -c $(CFLAGS) $(INCLUDEDIR) *.c
#	strip --remove-section=.comment *.o
#	strip --keep-file-symbols -R .comment *.o
# 	see objcopy...
#	as -o crt0.o crt0.s
#	ld -T linker.ld -Ttext $(RELOC) --entry $(ENTRY) -L$(LIBDIR) -o $(OUTF) $(OBJS) --warn-common
#	ld -T linker.ld -Ttext $(RELOC) --entry $(ENTRY) -L$(LIBDIR) -S -o $(OUTF) $(OBJS) --warn-common --strip-all
	ld -T linker.ld -Ttext $(RELOC) --entry $(ENTRY) -L$(LIBDIR) -S -o $(OUTF) $(OBJS) --warn-common 

clean: objremove
	rm -f *~ $(OUTF)

objremove:
	rm -f *.o

depend:
	makedepend $(INCLUDEDIR) *.c
